package ${package_name}.controller;

import com.jinhua.admin.service.ProductService;
import com.jinhua.config.IdUtil;
import com.jinhua.config.PaginationRequest;
import com.jinhua.config.Response;
import ${package_name}.service.${class_name}Service;
import ${package_name}.vo.${class_name}Vo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;


import javax.validation.Valid;

${import_package}


/**
* ${entity_name}的操作接口
*/
@RestController
@RequestMapping("${base_url}")
public class ${class_name}Controller {

@Autowired
p4jprivate ${class_name}Service ${lower_class_name}Service;

/**
* 添加或者修改${entity_name} %np4j*
* @return
*/
@PostMapping("save")
p4jpublic Response save${class_name}(@RequestBody ${class_name}Vo ${lower_class_name}Vo) {




if (${lower_class_name}Vo == null) {
return Response.error();
}


return Response.success(${lower_class_name}Service.save${class_name}(${lower_class_name}Vo));


}


/**
* 删除${entity_name} %n
p4j*
* @param ids ${entity_name}的Id的集合,例如1,2,3多个用英文,隔开 %n
p4j* @return
*/
@RequestMapping("del")
p4jpublic Response del${class_name}(Long[] ids) {

if (ids == null || ids.length == 0) {
return Response.error();
}

return Response.success(${lower_class_name}Service.del${class_name}ByIds(ids));

}

/**
* 查找${entity_name} %np4j*
* @return
*/
@RequestMapping("find")
p4jpublic Response find${class_name}(@RequestBody @Valid PaginationRequest<${class_name}Vo> request ) {
    if (request == null) {
    return Response.error();
    }
    ${class_name}Vo  ${lower_class_name}Vo = request.getQueryCriteria();
    if(${lower_class_name}Vo.getId()!=null){

    return Response.success(${lower_class_name}Service.find${class_name}ById(${lower_class_name}Vo.getId()));

    }

return Response.success(${lower_class_name}Service.find${class_name}ByAll(request));

}

}
